When applying graduate schools, what is the difference in the elements that go into writing a SoP for a Masters program vs. writing a SoP for a Ph.D. program.
As background, I'm looking into Computer Science graduate programs.
It depends on the differences between the MS and the PhD.
PhD programs are always research programs, so your statement of purpose is going to testify to your preparation for undertaking scholarship, your research interests, and your fit with the program in a research context. You'll name specific professors whose research interests align with yours; you might list some resources (like labs, archives, libraries, etc.) that the university has that make it a good fit for your work. Some students choose to say a little about their career goals and how the program will help you towards them, but there's really no need - if you're applying for a PhD program, professors will assume you want a research career (probably in academia).
If you are applying to a research-based MS that is designed to prepare scholars for further PhD student or for research-oriented careers, your statement probably won't be much different than a PhD statement. It may be advantageous to state that you want a research career and a PhD eventually for MS programs that explicitly state that they exist primarily to prepare students for the PhD.
However, if you are applying for a professional MS program, your statement will be a bit different. You still want to talk about experiences you've had that have prepared you for graduate study, but in addition to talking about research and some coursework, you also may want to mention professional non-academic prep (like work experience, internships, maybe even extracurriculars if they are highly relevant). You can still mention professors and research interests if you want, but it's not necessary. Instead, in the tailoring paragraph, you'll focus more on other resources that the university has - like close ties with employers, a co-op program, a specialization in your area, etc. And you'll want to close with a short statement about your career goals and how you think the program can help you reach those.
When I applied for graduate school, I applied to both PhD programs and master's programs in my field that were mostly for professional preparation. I used essentially the same template for both kinds of programs, but I put a little more emphasis on non-research resources at the prospective program and career preparation in the master's statements.