How do antibiotics treat viral infections?

They don't. Antibiotics are targetted at bacteria. There are also antifungals and a very few, quite new, not 100% effective anti-virals.