@Rickshaw Phil has nailed it (and
@midlife has provided illustration)
"what you have is a square taper crank and bottom bracket (crank axle). The crank arm is held onto the bottom bracket by a nut which has worked itself loose and should be hiding behind the silver trim on the crank arm, which will either unscrew or prise out.
"The bad news is that with it having come off while you were riding
it is possible that the tapered hole in the crank arm
will be is damaged."
But the good news is, and
@iluvmybike provides the solution: repair to your local bike shop (LBS) with the damaged crank, a decent packet of biscuits and a tenner (max): they will have one(several) the same length. Strongly suspect the nut is lodged behind the 'silver; crank bolt cap (see OP photo - just unscrew or flip that off), but if not ask LBS to rummage for a suitable nut (NB with a flange).
You do not need the tool that
@MichaelW2 shares, btw: the crank is already off.