In a brand new out of the box switch, is the IOS already installed or it is auto installed when we power on the switch.
Yes, IOS is installed on out of the box switches. If you buy them all at the same time and the same place (and they're the same model) then they will most likely have the same IOS version.
Having the same (or very close) version helps when you're stacking the switches (using the stacking cables in back to turn 2 to 9 switches into a single unit). If the version numbers are too far apart, the switches will not stack and you may need to upgrade the IOS on the older versioned switches manually. There's an auto upgrade feature but it doesn't always work like I would expect it to. :)
The point here is that even though the switches might be stacked and act as one unit, each switch still has and needs its own version of IOS. Even when upgrading a stacked set of switches, you need to copy the IOS on to each separate switch. The following link is for 3750 switches and there may be a newer one for 3850s but I doubt it will be much different. This contains all sorts of commands and instructions for stacking upgrading and copying IOS files between switches: