Using its own TERM is a deliberate design decision. I don't remember how to fix the terminal database, but it's pretty easy (your favorite search engine or LLM should be able to help you there).
Or the manual, which describes the features for automatically handling it.
i had to do this for ssh
host * SetEnv TERM=xterm-256color
I definitely have had to poke at things a bit, even where they "should" work. I use salt in my homelab and eventually got the xterm-ghostty.terminfo file and I put it in my baseline salt config, then you run 'tic -x xterm-ghostty.terminfo'.
https://ghostty.org/docs/help/terminfo#ssh