First, there are many more fields in mathematics than just Abstract Algebra and Analysis. For example, Number Theory is also very suitable for an MS thesis or PhD. There are several other fields, but they are somewhat less common.
Your PhD thesis is not really meant to be a follow up on the MS thesis. In both theses you are using the things you've learned in Algebra and Analysis class to go into the depth and investigate something. Since should have had plenty of courses in both fields, so you know the basics of each fields, you can switch form fields. However, since the Master thesis doesn't have to be original research, but the PhD has to be, you can use the MS thesis to review and expand your knowledge on one of the subjects so that if you write the PhD thesis about the same subject, you have a better ground to stand on. This might save time in you PhD thesis. In short, you can switch, but it might cost you some time and effort when you're writing your PhD thesis.