I see a lot of movies where soldiers shooting, but there commander says, "Fix bayonets" and they charge the enemys. But why didn't they have there bayonets on before hand?
I feel like it would be more practical because if a enemy was charging you, you would have to put on your bayonet or use your gun as a club. You wouldn't need to waste time putting on your bayonet. Was it harder to reload with a bayonet or something?
Extra question: Why were bayonets somethings to the side or on top of the barrel instead of directly below it?
There's always a fair amount of artistic liberty takem in movies and such, however bayonets not being affixed before the battle (or sometimes being fixed in the middle of one!) Is actually fairly realistic. A bayonet is, in essence, a several pound weight on the end of a long stick. It's a lot more exerting to aim or generally move around your gun with so much extra weight on the long end of it.
It also can generally just be awkward to handle. At a position such as right shoulder shift, oft used in the American Civil War, where the rifle would be brought up high to the shoulder and would extend well above your person, another foot or so of length provided by the bayonet would be easily caught in the branches of trees. Soldiers in the rear rank or in a column would be less able to use positions such as trail arms, where the rifle may extend too far forwards and interfere with troops to the front. It also makes reloading a bit more iffy, as you have to be somewhat careful to not stab yourself on the point while ramming your charge down the barrel.
In addition to all this, fighting in this period would generally take place at 100-200 yards. Generally speaking this would grant you enough time to fix bayonets even if you were unprepared, so this (in addition to those earlier points) is why commanders might wait to just before a melee or charge to fix bayonets.
To answer your final question: Bayonets couldn't be directly below the muzzle because then it would block the ramrod, at the same time you generally wouldn't have them directly above the muzzle because then they would block the soldier's view and make it a fair bit harder to aim accurately. For this reason you generally see them to the sides or at a diagonal.