What causes the redirects?
It's hard to give a simple answer, but I'll try.
The software which serves web pages, and which runs on the server, is called Apache. Apache is very configurable. If someone is able to mess with that configuration, they can do naughty things.
There is a main configuration file for Apache, which normally sits outside the directories full of web pages that Apache serves. Apache also supports per-directory configuration files, which sit in the directories they configure. These are called .htaccess files.
The .htaccess files in the top-level directory of each website on the server had been modified. Rules were added which told Apache to detect whether a request was coming from a mobile client, and if so, issue a redirect.
I fixed that problem, and locked those files down so it probably won't happen again. That doesn't explain how it happened; the fact something on the server
tried to modify those files confirms that there's a vulnerability somewhere in the system. Locking down those files is like locking your bedroom door at night; if that's what keeps you safe, your house is not secure. But it's no longer my system.