If You’re installing it in a subfolder, discourse needs to be configured for that. Otherwise, there is no way for it to know if it is serving traffic to subdomain or subfolder.
By pointing links to the subdomain, it is doing the right thing as it is expected to. You may have had some sort of redirect in place but I’m not aware of how Your forum was configured. Maybe first try figuring out if everything that was modified outside of discourse (proxies/redirect etc) are in check. If that’s all good, maybe try configuring the forum to be used on a subdomain through the recommended method per