It depends. All militaries use use a range of weapons for different means. As they say in the military, "the situation always dictates." In all honesty, chemical based projectiles are likely still the way to go in a realistic future because of their:
- Extremely low failure rate
- Ease of use
- Ease of repair
This is why, for nearly all of human history, despite amazing advancements, we used (and still use) variations of pointy sticks to kill each other - because they work most of the time, with little training, and are easily maintained in extreme environments.
(It could be argued that bullets are just another variation of a pointy stick. Lasers are just another form of burning people. Both carry the same hazards and advantages then as now. But that's besides the point.)
In the future, guided munitions, such as an electronically actuated bullet, are more likely, like those used in the Fifth Element, pictured below, used to hit a target behind Zorg:
The ZF-1 used in this scene is a multi-purpose weapon, which uses multi-purpose ammunition, and is integrated with other weapon systems such as darts, flame thrower, and freeze gun, among other lethal and non-lethal uses.
But in consideration of your original question.
With laser weapons:
- They could easily damage unprotected flesh
- Be safe for use in cases where hull breach (if spaceships are a consideration) is a concern
- Only need to be large enough to have a power source and a laser diode
- Power source could be adaptable
- No recoil
- Easily refracted or scattered (by smoke or materials) by environment (weather, armor, smoke)
- Field repair near impossible
- War is inherently dirty, lasers need to fire through clean lenses for max effectiveness
- Collateral damage is a great concern, due to ability to set things afire, and the inability to warn of misfire
- If there is a Geneva Convention-like law, burning people to death could be a legal concern under an "unusual cruelty" clause
On rail guns:
- Can penetrate through a variety of armor
- Not easily deflected
- Projectile not effected atmospheric concerns
Must be used in a vacuum, because recoil is either deadly in a handheld weapon...
Or the recoil is so violent, an auxiliary system is needed to compensate... Not amount of "technology" can account for huge amount of momentum, so there must be some system
- The rail must be perfectly clean, otherwise the barrel would explode lethally
- Ammunition is limited, even if it could be made very tiny
A HUGE con for both weapons:
- Both are susceptible Susceptible to EMP
But if they were used in an infantry squad:
- Lasers, preferred where hull penetration is a concern, or as a secondary weapon
- Railgun, anti-infantry/light armor weapon, standard ground combat
If there is a special weapons company/platoon, such as modern militaries have, which handle mortars, explosives, and machine guns - then such a weapons section may be better suited to handling the special purpose weapons while the infantry riflemen carry reliable chemical projectile weapons.
This would allow the railgun team to emplace and give supporting fire, as well as carry the necessary equipment to deal with recoil; and a laser team to carry the batteries and lens cleaning equipment for laser.
There could be a variety of sizes of lasers/railguns much like the modern military was well - some meant to be carried on foot-patrol, and others meant for base defense or long range support.
Be sure to acknowledge that a technological advanced military must not only have the ability to kill with sticks or bare hands, but also know how to use advanced communications/navigation equipment we don't currently have available, and know how to operate if that equipment is out of commission or damaged. (Such as knowledge to repair it or ad hoc it.)