You do not have to get your undergraduate and graduate degrees at the same school, but it will have benefits. Most schools structure the curricula of their undergraduate and graduate degrees in a way that they build off each other so that it will be a smoother transition.