My understanding is these rulings are both based on the constitution. The one on guns seems really straightforward:
"A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."
I know this can be interpreted differently but to me it reads that nobody should be restricted from arming themselves.
Regarding abortion, what aspect of the constitution would cover it?
I'm asking in good faith here btw.
Edit: separately, it is insane to me that these big decisions can be completely split along political lines. A 'supreme court' should be apolitical. There are so many issues with the way the US Supreme Court works. It needs total reform. You should be able to trust a court to make a decision based on the law, not their personal preferences.