Most times during a layover you'll be taking off on the same plane and if the layover is short then it's best to stay on the plane if they don't want you to leave.
You can get off the plane during the layover but you might have a harder time getting back onto the flight if you do.
If the layover is for an hour or less then it's best to just stay on the plane.
Best thing to do is ask the flight attendant on what you should do during the layover to get a good answer.