Strange dynamo behavior
It sounds like you have a bottle dynamo. Many are constructed poorly and have matching short lifespans.



Typical failure modes are:


Friction wheel is made of cheap plastic, rubber, or pot metal -- and wears down, breaks, or flies off
The wiring was done by drunken lemurs and breaks off inside
No sealing against water/dust/salt and it corrodes to pieces
The hinge mechanism is poorly constructed and breaks


In your case, it does sound like maybe the spring that forces the dynamo onto onto the tire sidewall isn't apply enough pressure. I'd put some oil on the spring and hinges and work the hinge back and forth a few times. The dynamo may have also rotated (fallen) off its mounting bracket slightly, you may need to rotate it back into position and tighten its screw more tightly.

The good news is that bottle dynamos are cheap enough to be easily replaceable when they do break.