When you are comparing a town home and a detached home within a similar price range you would expect to see the town home newer, large and with significant amenities. The detached home for the same price might be a smaller older home but have a larger lot than the town home. Add for some features, subtract for others and end up at the same price for both.
Buy the home you love, if a yard is important buy the detached home. If having all new amenities is more important, buy the big town house.
I agree with Jeff. Another way to look at it is how close would/do you want your neighbors? If you want a little space go with the detached house.
As to why are they priced the same.... Are the detached homes you looking at new like the townhomes? Are they the same square footage? Do they offer the same amenities? If the answer is yes to all three, then the only other mitigating factor would be the location. If the answers are no, then you have your reason....