Roman Emperors were divided into two groups. The senior Emperor was known as the Augustus, the lesser Emperor who answered to the senior and was often his successor was the Caesar. Although some Emperors were determined by succession (Commodus was the son of Marcus Aurelius) more often than not the Augustus chose his own successor, who was first the Caesar, and adopted him as his own son. Tiberias, who succeeded Caesar Augustus, was the latter's step-son; and Caligula ws Tiberia's grandson. Claudius, who succeeded Caligula, was the former's uncle. Contrary to the above answer, Augustus was the second emperor; the first was Julius Caesar who chose Octavian, his nephew, as his successor.
The choice of successor, although normally made by the Augustus, often depended on the support of the Praetorian Guard. They were the Emperor's body guard, and their support was necessary for his survival. If one did not have the support of the guard, as was the case with Caligula, he was not apt to last long.
The military was a factor at times (but not always) as Roman soldiers were sworn to loyalty to their commanding officer, not to the Empire. This was a practice initiated by Julius Caesar who paid his troops from his own funds. At times a powerful military leader might be proclaimed Caesar (or Augustus) by his troops, and the result was quite often civil war. It was just such a civil war which led to the end of the Empire: the last emperor, Romulus II Augustulus, was a feeble minded boy placed on the throne by his father, a powerful general. Odoacher, a Visigothic king fighting for the Romans deposed Romulus, sent the scepter and royal robe to Constantinople with a letter informing the Emperor there that he was then the sole Roman emperor.
This is an excellent question. There are many variables in how a person becomes a Roman Emperor. I would say that there were generally speaking three different ways.
First, as in most places of the world, might makes right. So, if a person conquered all of his foes, then he could become emperor. We see this in the Empire in many occasions. For example, Augustus, the first emperor was the last man standing after many civil wars. The same can be stated with Constantine, who defeated all rivals to become the sole power.
Second, if an emperor was able to establish his rule securely, then his son would most likely be emperor. We see this in times of peace and stability. For example, Augustus's adopted son Tiberius became the second emperor. After Tiberius the next three emperors were from the same family - Gaius, Claudius and Nero.
Third, when the empire was in disarray, the military had a huge role in electing emperors. In other words, generals will get their armies to back them. Often there was no contest; this is why there were a string of "military" emperors.