Newton's first law of motion - sometimes referred to as the law of inertia. An object at rest stays at rest and an object in motion stays in motion with the same speed and in the same direction unless acted upon by an unbalanced force.
If the train is moving with constant velocity.In this case, suppose the mosquito sit firmly till train attained constant speed. Now, the case is different. The whole train, alongwith its passengers and our little mosquito friend are moving with same velocity. Now, if the mosquito decides to get up and take a ride, it is blessed by mother physics. Through frame of reference of mosquito, the train is stationary, all its parts are stationary. So, it will very easily be able to FLY NORMALLY. And i hope this answers second part of your question as well. The mosquito is not (and obviously can't) competing with the speed of train. It is just possessing same inertia.
Newton's second law (Law of Force and Acceleration) states that the acceleration of an object is basedoff of its mass and the force acting upon it. This picture shows this law because the ball went farther because it is lighter than the pumpkin.