So one thing I don't understand is how did the supreme court make gay marriage legal? If it's a law, I thought only the president could make laws
Wrong on pretty much every count, but explaining why involves a fair bit of education on the US government system.
So the US government is divided into three branches - Legislative, Judicial, and Executive. The
idea of the separation of powers is to prevent the uprising of a tyrant/despot/monarch and also to prevent issues that had been prevalent in other systems of divided government that had been tried previously (mainly the Republic of ancient Rome and the Athenian democracy). In reality, especially in the modern day, the line between the branches has been blurred, especially between the Legislative and Executive branches.
The Legislative branch is Congress, which is two pieces, the Senate and the House of Representatives. Essentially, these two bodies of many Senators and Representatives elected by their home states are the lawmakers. For something to become federal law in the US, it must be submitted to either the Senate or the House as a bill, then sent to committee, very often undergoing many changes in the process. Once it makes it through committee, it has to be voted on, and then even if it passes one body, it then has to pass in the other as the exact same bill. If similar (but slightly different) versions of a bill pass both bodies, there is a process called reconciliation, but it's a bit complicated and I won't get into it.
Basically, once the bill passes a vote in both the Senate and the House of Reps, it's law from that point on, with a couple of exceptions I'll get into later.
Then there's the Executive branch. This is the smallest branch, and it originally just consisted of the President. Nowadays, it has come to encompass the President and his Cabinet. The idea of the Executive branch is to
execute the will of the government. That is why the President, who is a civilian, is the supreme commander of the US armed forces. Additionally, that role was (in theory) designed to make a military takeover of the government more difficult. The current President is always in charge of the military, so to overthrow the government they would have to start with their own leader.
One very common misconception is that the President can make laws. This is not true. The President has some control over the Legislative branch (again, I'll get into that later), but cannot actually make laws himself. What the President
can do is issue an Executive Order, which is a catchall term for the mandate of the President. Mostly these have to do with the armed forces; for example, executive orders both created and repealed the Don't Ask Don't Tell policy amongst US military. They can also do other things, but again that's a bit more technical and I won't get into it here.
Other powers do come with the Executive branch; the founding fathers were aware that in times of crisis, dissenting opinions can be very detrimental to the nation's ability to act, so the President can, in theory, take direct command of the armed forces and government in general for a limited period of time when necessary. This power is rarely used (I believe last used by Bush after 9/11), and there is a time limit that I have forgotten by which the President must justify himself to Congress.
Finally, there's the Judicial branch, which consists mostly of the Supreme Court, although technically all federal courts are part of the Judicial branch of the US government. In reality, the overwhelming majority of the constitutional duties of the Judicial branch are done by the Supreme Court, and the more mundane, day-to-day issues are dealt with by the lower levels of the federal court system. What exactly the Supreme Court does is a bit complicated and is best described in general terms: they interpret the law.
So, in super general terms, the Legislative branch makes the law, the Judicial branch interprets the law, and the Executive branch enforces the law.
However, the founding fathers were very wary of this system working in isolation. So they implemented what are referred to now as "checks and balances"; that is, each branch has ways they can "check" or "balance" the powers of the other branches, in order to prevent one branch from becoming too powerful. The most famous example is the Presidental veto; any bills signed into law by Congress must be signed by the President. If he does not sign, he vetoes the bill, which sends it back to Congress. But Congress can override a veto with a sufficiently substantial majority (2/3 required in both the Senate and the House of Reps, rather than just the >50% required for the bill to pass normally). The President and Congress also have checks on the Judicial branch because they control the judges that get assigned to the Supreme Court for life. The President must nominate candidates, which Congress must approve.
Now that you understand all this, I can explain the Supreme Court decision: the Supreme Court interprets the law, and in this case they were dealing with a court case over whether a state's law that banned same-sex marriage was Constitutional. Understand that the Supreme Court is not supposed to determine what is right or wrong, just what is according to the Constitution, so once they state something is unconstitutional, it is gone. That is the reason that Supreme Court decisions are such a big deal: once they determine something one way or the other, the issue is closed and it is determined constitutional or unconstitutional (until the Constitution changes, of course, which has not happened in quite a while).
In this case, by a narrow vote of 5-4, the Supreme Court determined that by the
14th Amendment, which primarily states that all citizens must have equal rights, banning same sex marriage is unconstitutional because it denies certain citizens rights that other citizens have. Therefore, all state-based bans on gay marriage were instantly repealed and can never be reinstated.
Most modern-day governments are based on the Constitution, so this type of government is what most countries use nowadays, with their own modifications, of course.