How transaction gets into the block?
Unconfirmed bitcoin transactions are added to the memory pool (also known as mempool) by the senders.
From there miners are picking the transactions with higher fees first.