I have worked at several ports. If I worked directly on the water, like driving a patrol boat in the harbor, I might say I worked "in" the port. If I was a longshoreman, crane operator, truck or forklift driver, etc. I would work "at" the port. "I work at the Port of Seattle," for example.
Distantly related perhaps. The precise origin of "ham" in Hamburg is uncertain, I believe.
Swedish "hamn" / English "harbor", "port" = From Old Norse hǫfn, from Proto-Germanic *habnō. (https://en.wiktionary.org/wiki/hamn#Etymology_2)
Proto-Germanic "*habnō"... harbor, haven (https://en.wiktionary.org/wiki/Reconstruction:Proto-Germanic/habnō)
German "Hamburg" = In A.D. 825, construction started on the Hammaburg, or Hamma Castle, on ground between the Elbe and Alster rivers. It is from this structure that the city takes its name.
The origin of "ham" in Hamburg seems uncertain but English "harbor"/Swedish "hamn" do not appear to be directly related (https://en.wikipedia.org/wiki/History_of_Hamburg#Etymology).
Boddason points out below, the German Wiki suggests three possibilities as well for "hamma" in Hammaburg but my German is not good enough to translate it into English. (https://de.wikipedia.org/wiki/Hammaburg)
There seems to be a less common Swedish-English translation of "hamn" as "haven" which is intriguing in the context of "Hamburg" but I can't find links here and it doesn't appear in the Hamburg word origin discussions that I've seen.