Yorktown sits on a hill overlooking the York River. Which can be great, if you can keep provisioned.
The British were not able to keep provisioned, though. The American Army laid siege to the city, surrounding it on three sides, while the French Navy cut off the water access to Yorktown and cut Lord Cornwallis' army off from its supplies.