Since every IoT device uses different operating system, and has different hardware architecture, with so many possible platforms, how does Mirai infect them?
Actually, the Mirai virus was looking for a specific vulnerability present in the Linux operating system.
The Mirai virus targeted Linux devices running telnet via busybox. If busybox is not installed on the Linux device, the exploit fails as Mirai uses busybox specific commands. If busybox is confirmed to exists, Mirai then performs a bruteforce attack on specific ports numbers that are running telnet. How is this bruteforce attack being conducted? It is simply using a dictionary of the most common default username and password combinations. Once inside the system, Mirai looks for other target machines to infect. Here is a list of the Mirai's dictionary.
Unfortunately, many owners of IoT devices connect their devices to the Internet and never bothered to change the default login credentials. Here is a list of devices targeted by Mirai. More information can be found on the Mirai virus here.