You probably pressed E to extrude and then cancelled. The Extrude operation is actually two operations: Extrude and Move. When you cancel after E, you cancel the Move operation, but not the extrusion. This creates the double vertices.
Happens a lot, especially with beginners.
Two things you should always do when encountering strange behavior are:
First get rid of possible doubles (Merge by Distance).
Then check the Normals: you can turn on Face Normals in the Viewport Overlays dropdown. (SHIFT+N with everything selected in Edit Mode re-calculates the Normals and usually solves the problem). In that order, because if you have double vertices in your mesh, the re-calcution of the Normals might not work correctly.