How can I fix my door frame
To do it right a new piece of trim that matches or 3 new ones around the inside would be a start. An over sized strike plate (the part the latch drops into) and a couple of longer screws to secure the strike plate. Then find a small flat blade screwdriver to keep close in case this happens again. Most of these doors have a small hole in the outside knob. With the door open practice unlocking it. Some only need to push the button out, some you need to turn to get them to unlock.