The meaning of "town" is relative: it depends upon where you are. It has no constant meaning. Suppose you live in Manhattan, but away from the center. Then, going "to town" would mean going towards the center of Manhattan. Even though the place where you live has one of the highest population densities in the U.S., you would still not regard your home as being "in town". However, if you visited your friend across the river in New Jersey, you could refer to returning home as going back "to town". Thus your home is both "in town" and "not in town", depending upon where you are and how you are thinking.
"Town" is also used as a term to denote an urban area where there is much activity. The expression "to hit the town" means to go into an urban place where there is much to do.