There are many ways. IN the case of something like the Colosseum, since Rome had been continuously inhabited since its use, then no one ever forgot what it was. Quite hard to miss really:) Of course modern archeologists and historians add more information about it as time goes on through new discoveries both archeological and from texts.
Another common way to identify an ancient ruin is by comparing it to other known sites. For example a Roman villa or fort had a standard layout, therefor new finds can be compared to these known ones.
Another way is the finds that are taken from the site. For example if you find evidence of burning, and lots of broken pottery, and the outline conforms to the shape of a kiln, then you probably have a pottery producing center. If there are lots of bits of broken metal objects around, then maybe a metal recycling center.
Of course there are also many sites where we don’t know what they were for, just lots of theories. The most famous of these is probably Stonehenge in the UK, but there are many, many more.
I am sure there are more which someone else can explain. Hope that helped.
Many ruins are still in cities that have been lived in continuously, or still have some locals with a memory of what they were.
Past a certain point in history there are often relatively accurate surveyed maps you can use to identify sites, this helps a lot for colonial era sites in the Americas.
In other situations you actually find writing on the ruins that tells you what they are directly. The ancient Assyrian king Ashurnasirpal II wrote his name and lineage over and over again on the walls and carvings of his palace to the point it became known as his Standard Inscription. Egyptians famously wrote all over everything too.
In still other cases you can find these things but not clearly connect the specific sites, references in books and ancient texts, inscriptions, etc. This famously happened with Troy where the wrong level of the city was identified as the famous one, references to it in contemporary sources like the Hittite archives aren’t really confirmed, and so on.
It’s a whole spectrum of answers based on what you find in the ruins and how they existed after their heyday.
Latest Answers