They machine a wide ledge on the titanium, so the window is pushed into the groove/sill under pressure, basically a large window that is covering a smaller hole that it can't fit through. For all practical purposes, it justs sits on there and the pressure holds it on. It would also have bolts and/or sealant to keep it in place when not diving.
This sub was a carbon fiber cylinder with two titanium end-caps, and the porthole was fitted into the forward end-cap.