If a history buff mentions a sub, she's probably referring to an underwater warship. But if your friend wants a sub for lunch, he hasn't suddenly developed a taste for warships — he just wants a sandwich.
Sub is short for submarine, the cylindrical watercraft with rounded ends that can operate deep beneath the water. Sub can also refer to a long sandwich filled with meat, cheese, and veggies; this kind of sub goes by different names in different parts of the country, including hero, hoagie, and grinder. The sub in your geometry classroom is probably just a substitute teacher.