Also, in case you didn't know (which you obviously don't), a mob always have the same ID. That's what makes them unique. What a bot basically do (and what you can do yourself without a bot), is to make the <t> loaded in to your memory point to a specific mob ID, and thus, when you provoke, provoke said mob without having to touch it. Nowadays, most bots do ti automatically, but they still target specific mob-ID's, as they are always the same. So basically, they have a mob targeted before it even pops.
One of the reasons SE made it not possible to do "/ma Dia" etc. without a target after, was that you used to be able to manually insert a mob ID, such as "/ma Dia <mobID>", and thus still target specific mobs without the use of external programs.
Naturally bots can be beaten, as they are automated programs, and a lot of people do as they've had a lot of practice at it. Usually it requires good connection, and above all, a good computer. A bot doesn't really need either, but they still benefit from it. Thus why most people who bot chose to lower their graphical settings.
Also, SE sometimes change their mob ID's after updates. Those are the times when you used to see several people DC'ing at camps, who weren't expert botters and simply used one they downloaded or were provided by their shell.