I am not jis but I just returned from a trip to India last week and did ride a few "standard" trains (as opposed to the superior Rajdhani trains that jis rides) and I can provide some insight into this- as the Guest mentioned, normal non-AC or even AC coaches
do not get locked when the train is in operation. However it is customary during night time for passengers, or coach attendant (present only in air-conditioned coaches) to close the door and put a heavy latch that comes standard at every door. Now, to clarify the confusion between "locked" and "latched", the latch mechanism is such that from
inside the coach, anyone can go and open the latch, and the door, so nobody can theoretically get "locked" inside. However, if the door has been closed with the latch from inside there is absolutely no way for anyone to open the door from
outside even in case of emergency. So, the coach is
"latched" from inside, "locked" from outside.
So, in case of fire, if passengers
inside the coach have spatial awareness, they can open the heavy latch and throw the door open, but if an outsider wants to help them escape, he/she is out of luck since the door cannot be opened from outside when it is latched from inside.
Here is a photo of the arrangement I found via Google search, this is one of the newer LHB design coaches, but the usual standard design coaches have a similar arrangement. You can see three latches here- one at the top right, red one at the door knob level, and one at the very bottom right. The bottom one is rarely used, the other two can be opened and closed from inside by anyone.