It may an act of veneration and drawing closer to the one to whom one prostrates. This kind of prostration is worship, and should only be done for Allaah, according to the laws of the Prophets.
The second type is a kind of greeting and honouring a person. This is the kind of prostration which Allaah commanded the angels to do in the case of Adam, so they ...
Prostrate was to Allah; not to Adam. It was for Adam.
Allah said to do sijda (to Allah) for (making) Adam, a "Superb" creation.
Similarly, Yousaf's brothers bowed to Allah.
The Arabic word in Quran is "lee" meaning "for", it is not "to"!