iMac Wi-Fi detects internet networks but it doesn't connect to any, but my other PC connects fine to them My iMac Wi-Fi detects internet networks but it doesn't connect to any, but my other PC connects fine to them.

It is a second hand iMac, it worked fine when I set it up, it connected for a day or 2 then no more. It still can detect the network but can't connect. With another PC of mine I can connect fine to the network I'm used to and the same one that the iMac worked with for the first 2 days.
Assuming you've already tried rebooting the iMac, you could try totally removing your Wi-Fi service, restarting your Mac, and adding your Wi-Fi service back again to see if that resolves the issue.

While you don't specify your version of macOS, the steps below should work:


Go to Apple > System Preferences > Network
Select the Wi-Fi service on the left-hand side
Click on the cog icon at bottom-left and select Make Service Inactive
Now delete the service by clicking on the minus sign (i.e. the - button) at left of the cog
Click on the Apply button
Exit Network preferences
Restart your iMac 
Go to Apple > System Preferences > Network
Click on the plus sign (i.e. the + button) at left of the cog
In the pop-up window, ensure that Wi-Fi is selected from the drop-down menu
Click on the Create button
Make sure Wi-Fi is on


Let me know if this resolves the issue.