In order to learn songs quickly by ear, or to play along with other musicians on a song you don't know, you first need to find the key of the song. There are several strategies for finding the key, and eventually you will be able to do this almost subconsciously, without needing to think about the clues and techniques you are using.
To find the key of a song, you must find the tonic. In the key of C Major or C Minor, the tonic or '1' is C. The notes in a scale or key are like a family - they are all related, and they center around the '1' or the tonic of the key. This is the tone that sounds most 'at home' - the one that fits better than any other note.
If you're new to this process, just start playing notes one-by-one over the song you want to learn, and observe how they sound. The tonic will sound like it fits just about anywhere in the song. When you have a candidate for the tonic, next play the tone a fifth above your candidate. The '5' is always the second most stable tone in any key. This tone will also sound like it fits in most parts of the song, though not as strongly as the tonic.
If your candidate tonic note and the note a fifth above it both sound fairly stable, next try the note a half-step below your candidate tonic. If your guess is correct, this note will be the '7'. In most parts of the song, the '7' should sound like it is 'pulling' toward the tonic. If you feel tension when you play the '7', then resolution or stability when you play your tonic guess a half-step up, there's a good chance that you have found the tonic.
Finally, if you can't tell whether the key is major or minor, try playing the tone a minor third up from the tonic ('b3') throughout the song and compare it with the sound of the tone that is a major third up from the tonic. In general, the tonic and b3 (minor third interval) will match with a minor key, while the tonic and 3 (major third interval) fits with a major key.
The above process may take a bit of work at first if you've never done it before, but eventually you will begin to recognize the sound of the tonic quickly without having to consciously go through all these steps. Spend some time practicing with a mix of songs you like, just trying to find the key for each one. Let me know if you find one that's challenging!