Six is normally best for maximum amount of ore balanced against random infection. 3 would reduce the amount of infection, but you might struggle to find enough ore. Every 3 altars you smash reduces the amount of ore that spawns, but still increases the amount of infection spawned.
Six seems to be the right amount, for me at least. Though, if you're willing to spend the time, you can fish for HM crates and get ore from those, which would avoid the infection spread problem with smashing altars.
3 in my opinion. because what others said too, each smashed altar has 1/3 chance to corrupt(/crimson/hallow) a random single corruptible block somewhere underground, creating new pockets of these biomes.
6 can work, but yeah, the 2nd series of altars (4th, 5th and 6th smashed) will only give half the amount of ores the 1st series gave. it doesn't quite worth it, IMO.
or just like @Calen said, you can just go fishing, and get hardmode ores that way, which is slow, but you can avoid smashing any altars.
and one more thing to note! once you smashed 1 altar, the pirates and the mech bosses can attack on their own. mech bosses aren't much a problem, since they despawn after killing you, or you can just wait it out underground that the morning comes and they won't spawn, but the pirates can be very tough at the start of hardmode. so, I would recommend trying to get at least one hardmode weapon before smashing any altars, so you have a bit better odds against the pirates, in case if they invade before you could mine enough ore for armors, etc.
If you say you're ranger, the arms dealer has the shotgun for sale right from the start of hardmode. crafting some hardmode ammo and an infinite musket ball pouch/quiver also could be useful.