I have similar issue with my Powershell terminal and I found that the cause of the issue was enabling the Command Not Found module of the PowerToys app in the windows.
It adds these lines to the $profile
file:
#f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module
Import-Module -Name Microsoft.WinGet.CommandNotFound
#f45873b3-b655-43a6-b217-97c00aa0db58
I removed them and the problem was resolved.
to edit this file you can use notepad $profile
in the terminal.