The person getting on the elevator should stand to the side and wait for others to exit before stepping in.
The person inside and closest to the elevator door exits first.
The person nearest to the control panel should offer to push the elevator buttons for others.
A person who is standing far away from the control panel should “politely ask” if the person nearest the panel would push the button for their floor.
Now, if the doors are closing and:
You are inside the elevator and you see someone coming, at least make an attempt to push the button to reopen the door.
You are outside the elevator and you see the door wide open, people inside, enough room for you (and your stuff) and you are just 2 to 3 steps away, then and only then may you say “Hold the door please”.
You are outside the elevator and you see the elevator door inches from closing. Just accept it as a sign that you were not supposed to get on that elevator and wait for the next.
Finally, for everyone’s safety, don’t thrust any body parts, briefcases, or bags, strollers or children in between a closing elevator door.