There are numerous different circumstances when people marry and/or change their names. There is clearly no general rule on this, as the question hints already. Let me describe the ways.
First, conventions. There are not two but really four types of surnames we are talking about:
a) full legal name (usually found in passports)
b) professional name (university websites, wikipedia)
c) pen name (used to author papers, see arXiv, mathscinet)
d) maiden names and other former names
I believe neither two have to be the same, some people have more than one version of at least one of these items (say, have two passports from different countries, or publish under two different names, whatever), and occasionally people have different all four.
a) Julia Hall Bowman Robinson, b),c) Julia Robinson, d) Julia Bowman
b) Sofia Kovalevskaya, c) Sophie Kowalevski, d) Sofia Vasilyevna Korvin-Krukovsky
as for a), I am not sure if there was a passport back then; if issued today she would have a passport in the name Sofia Vasilyevna Kovalevskaya (modern transliteration, changed several times)
a),b) Mary Ellen Rudin, d) Mary Ellen Estill, c) published first as Estill, then as Rudin
a),b),c) Cathleen Synge Morawetz, d) Cathleen Synge (published also with S. as an initial)
a) Ruth Elke Lawrence-Naimark, b),d) Ruth Elke Lawrence, c) Ruth Lawrence
a),b) Dmitry Feichtner-Kozlov, c),d) Dmitry N. Kozlov (although Russian passport is notoriously difficult to change, and usually continues to have maiden name).
P.S. To further appreciate complexity arising sometimes, consider e.g. this explanation by Paco Santos (ht Gil Kalai).