What was the logic behind annexing a piece of land that had never been part of the Russian Empire? I have heard it was due to needing a port that wouldn't freeze in Winter, but wouldn't ports in Lithuania and Latvia serve that purpose?
To an extent, the Kaliningrad transfer to the hands of the Soviet Union was supposed to be a temporary settlement - as the postwar borders drawn after World War II severed the modern day Kaliningrad Oblast from the rest of Germany and "Germany" as a country ceased to exist, transferring the control of the territory to the Soviet Union, which now bordered the territory, was a natural conclusion.
Though by then it was effectively symbolic, this temporary control was only made permanent in 1990 with the Treaty on the Final Settlement with Respect to Germany, during which the newly restored united Germany waived all of its Eastern claims, including the Kaliningrad oblast. Officially, until this agreement was signed, the Soviet Union was merely taking care of the territory before a final decision over its ownership could be made - of course, at a first glance, it did not seem that way, as it had been fully integrated into the USSR's internal structure and was treated as an ordinary Oblast within the RSFSR.
Now why Kaliningrad stayed in the Soviet Union is because it has been pretty thoroughly severed from the rest of Germany after World War II. It suffered more than almost any other place in the world during the war, and it is estimated that only a tenth of its original population remained - those who were not killed either fled or were expelled. A completely barren land such as Kaliningrad thus had to be resettled, which the Soviet Union did very actively. It was only when this resettlement began that the plans you speak of, such as using it as a warm water port, came about. It was indeed used as a warm water port for the Baltic Fleet, as Leningrad (or St. Petersburg) freezes during winter - indeed, Lithuanian and Latvian ports were also ice-free and used for various purposes, but many of them were too small, and the Baltic SSRs were considered to be unreliable. It was much less risky to place a military object of strategic importance in a completely Russified Kaliningrad, which also inherited naval facilities from the German era.
Of course, there were also patriotic feelings at play. Koenigsberg and East Prussia in general are connected to the Teutonic Order, a historical enemy of the Russian principalities which Alexander Nevsky defeated in the Battle of the Ice, one of the biggest moments in Russian national identity. To conquer the capital of the despised Germanic orders and turn it into a proud Russian city certainly played some role in the decisions of the largely Russian bureaucratic apparatus of the USSR.