They were afraid of large numbers of Jews coming in from (in the case of the St. Louis) Germany. 900 people is a lot of people but it would only be the tip of the iceberg if people were allowed to cross the Atlantic and go into the United States. There was a quota of how many people could come in and the US wanted to keep to the quota system.
The United States (at the time of the St. Louis sailing) was neutral, so they also didn't want to endanger that neutrality.