A can is a metal container. A jar is made of glass. :)
We know when we mean can (a container) and can (ability) because one functions as a noun and one functions as a helping verb. You can see this by the word order in the sentence, or the presence of other words... for example, "can" (ability) always has another verb that follows it.
Look at the sentence, not just the word, and the difference is very clear.