What you mention is technically known as "homonymy", and it was theoretically observed and practically used by the ancients. There are different types and many examples can be given: Cicero plays with the homonymy of the proper name Verres (the corrupt governor of Sicily whom Cicero attacked in the Verrines) and the noun uerres 'male-pig'. As for the theoretical side, you can fruitfully read a passage from Quintilian's Institutio oratoria (book 7, chapter 9), where he, when dealing with ambiguity, mentions several types of homonymy and homography, e. g. Coruinum (proper name) / cor uinum (two nouns) / Gallus (man from Gaul) / gallus (cock) / gallus (priest of Cybele), in occulto loco "in a hidden place" / inocculto loco "a non-hidden place'... and many more (he also refers to the famous aio te, Aeacica, uincere Romanus...). This is not the only passage where Quintilian deals with the liguistic problem of homonymy and polysemy: in book one, he mentions the rare homonymy between fraudator ('a deceiver') and fraudator as an imperative passive form (very rarely used, indeed!) of the verb fraudo
There is a lot of literature dealing with the topic of puns based on homonymy. I can try to select some references for those who may be interested-