I'm assuming that the green line is the Y axis, but if that's not the case change the axis accordingly.
Go to edit mode, select all and press S, Y, 0, Enter.
This will force all vertices to scale along Y axis until they share the same exact Y coordinate.
To avoid the problem in future, you have to understand the stroke placement options and the drawing plane options, that once you try a couple of experiments, should be self explanatory.
(https://docs.blender.org/manual/en/latest/grease_pencil/modes/draw/stroke_placement.html, https://docs.blender.org/manual/en/latest/grease_pencil/modes/draw/drawing_planes.html)
Another way is to clean up the drawning with the reproject strokes function: