They look alike and I'm not exactly sure what's the difference
They look alike because they use the TO-220 package.
TO stands for "Transistor" "Outline" and Number 220 is the "outline" or package "design", meaning it adheres to specific dimensions.
The only way you know "what goes on inside" is to, for example, "Google" for a DATASHEET based on the stamped part number.
7812 - http://pdf.datasheetcatalog.com/datasheet/motorola/MC7809.pdf
TIP122 - http://pdf.datasheetcatalog.com/datasheet/fairchild/TIP122.pdf