--snip--
i didn't understand this paragraph, can you explain more, please?
Any wallet you use has an algorithm (or multiple algorithms) for estimating the transaction fee.
These algorithms usually look at the current mempool (and sometimes the most recent blocks): how many transactions are in there, what is the type of transaction and what is it's fee (in sat/vbyte). Based on this information, the algorithm proposes a fee that, to a certain degree of certainty, has a decent chance of getting your transaction confirmed within a certain couple of (future) blocks.
It all boils down to the fact that a miner can only fit 1 Mb of transaction data (disregarding the witness data) into any block they're trying to solve. Since there is a space constraint, the miner usually picks the unconfirmed transactions from it's mempool that have the highest fee per virtual byte of data. What a wallet is doing is trying to get your transaction into the top x Mb of transactions in most mempools (your transaction doesn't HAVE to be in the top 1Mb if you indicate you're willing to wait, let's say, 30 blocks). This isn't an exact science, since the wallet has no idear how many new transactions will be broadcasted the next couple of hours, and what their fee will be... The only thing a wallet can do is make an educated guess based on the recent history and the current state of the mempool.