Since $M$ is a closed manifold and $gf$ is homotopic to the identity, it must be surjective, otherwise it wouldn't preserve the fundamental class mod 2. In particular $g$ is surjective. Your isotopy condition implies that $fg$ is a homeomorphism onto the image, which coincides with the image of $f$ since $g$ is onto. The image of $f$ is compact since $M$ is compact, so $N$ should be compact too.