Why a URL with a query is always slower than that without a query?

When you run a search (you call it a query) WordPress must use its DBMS (MariaDB / MySQL) to examine the entire text of every post, page, and user on your site. That takes time. There are some plugins out there to make search more efficient, but it is still work for your site to do.

I like the Relevanssi plugin for improving search.