The Prussia that emerged as a significant European force was originally the margraviate and later prince-electorate of Brandenburg. Similar to other European feudal family states, Brandenburg grew its land slowly and steadily in the beginning, mainly through marriages and inheritance.
It is really important to understand that the Prussia that many usually refer to when talking stating the term refers to was a Polish vassal that was the remainder of the Teutonic Order state that was transformed into a secular duchy. This Prussia was indeed a Polish vassal - Brandenburg never was. After having acquired Prussia, the prince-elector of Brandenburg within the Holy Roman Empire was also duke in Prussia (the "in" becomes important later).
I could elaborate on the "Great Elector" (Großer Kurfürst) and his desire for fame and prestige, but to be brief: the prince-elector and his son Friedrich (both Hohenzollern) aspired to become equals with the powerful figures in the empire, such as kings, and spent large amounts of money to campaign for that title. Because the emperor did not want to give such a prestigious title to someone who could potentially challenge his power, they made a costly deal where the person could only refer to themselves as king outside of the empire. Because the former Teutonic Order lands were situated beyond the empire's borders, the prince-electors of Brandenburg were permitted to use the title of kings in Prussia, rather than of Prussia. Therefore, since a simpler explanation was unavailable, they decided to declassify their original name, Brandenburg, and began referring to themselves as Kings in Prussia. Once more, they were not truly subordinate to the king of Poland, but instead used the title to raise their status to higher levels. Poland was officially the superior ruler of the "original" Prussia.
This is a drastically shortened version of what happened, and there are many factors that play into almost every segment I touched on, so don't take this oversimplification verbatim.