They are named for the people involved. The rules vary slightly state to state, but here is the typical scenario:
People v. Smith or State v. Smith
If you're referring to a case from one state, but you're in another, like for example, if you're in New York and you're referring to a Texas criminal case against Smith, you'd call it Texas v. Smith
Both parties are the names of either people or entities. Entities can be companies or governments. People can also be sued as themselves or as representatives of companies. Here's some typical examples:
Smith v. Jones
Smith v. State of Texas
Smith v. Acme, Inc.
XYZ Corp. v, Acme, Inc.
XYZ Corp. v. Jones, as Secretary of State of New York
For an appeal, in most states and also in federal court, the one who brings the appeal goes first, but otherwise the rules are the same. Some states do it differently, but it's unusual. For example, there was a famous criminal case in Arizona against a man named Miranda. In Arizona, it was called State v. Miranda. Other states called it Arizona v. Miranda. Miranda was convicted and he appealed all the way up to the Supreme Court. Since Miranda was the one calling for the appeal, his name went first. The appeal in the Supreme Court is called:
Miranda v. Arizona
That's where we get the term "Miranda rights".
That's the reference book lawyers use to figure this stuff out. The rules get a lot more detailed with all kinds of formalized abbreviations and different ways to refer to the reporters and methods to cite every source you can think of.