If the iPod is not formatted for Mac, Windows thinks it needs to be formatted for some other reason. That message you described ("windows needs to format the device for it to work in windows") sounds like it came from Windows, not from iTunes. If the iPod is still functioning properly (as an iPod) and playing its music, you may want to connect it to another computer, as a test to see of the same message appears.
NOTE: "Another computer" can be a Mac, because Macs can access the Windows disk format.
Make sure you do not sync it with an iTunes library or do a Restore if prompted, because those actions will erase the iPod; don't even run iTunes on that other computer. But IF the other computer can access the iPod without an error message about needing to format its storage, use one of the third-party methods or utilities to off-load the iPod's songs there. Then, transfer the song files to your computer and add them to your iTunes library. You can then connect the iPod to your usual computer and trouble-shoot it there (including doing a Restore in it) without concern about losing your songs, because its songs are now in your iTunes library.
Going forward, you should back up your complete iTunes library, in case your computer or its drive fails. Here's how you can back it up to an external drive
Manage and back up your iTunes media library - Apple Support
An iPod is not designed to be your iTunes data backup, and it's risky to only have your songs stored on an iPod. It can break, get lost, or have data corruption (requiring a Restore).