How to make a DC motor act as some sort of switch

A button or switch does not produce a voltage. It either makes or breaks a connection.

A brushed DC motor is a generator and will produce a voltage, positive or negative, depending on which direction the shaft is rotated.