It is not possible to be absolutely sure about what factors account for this and which of those factors is most important. Let us look at a few possible factors.
These laws became popular at a time of relatively high crime. In addition, crime was played up by the media and by politicians. At times like these, it is typical for Americans to favor “get tough on crime” policies.
Americans tend to believe in punishment more than rehabilitation. Our culture is relatively unsympathetic towards criminals. We tend to see them as bad people who must be punished, preferably harshly. We tend to see crime as an issue of people’s morality, not an issue that is caused in large part by the economic and social opportunities that are open to people. Since we see criminals in this way, we tend to want to punish them harshly.
We tend to see crime at least partly through the lens of race. Non-whites in our society commit a disproportionate number of crimes. This allows the white majority to feel less of a connection with people who commit crimes. It is somewhat easier to create harsh laws if we think that the people they will punish are not “like us” in racial (and, as stated above, in moral) terms.
I would argue that these are the main reasons for the popularity of these laws.