I have an electrum wallet. I did two transactions and set fee as minimum in both cases. In first cases the fee was 0.00008686 BTC (61.8 sat/vB) while in second it is 0.00012295 BTC (87.5 sat/vB).
I want to know why FEE is different in both cases? In both transaction I set fee to minimum.
On what principle these fee are calculated?
The total block weight is limited... Basically, this means that in a block there's only place for 1 Mb of transactions, but witness data of segwit transactions doesn't count for this 1 Mb limit (it has a higher limit).
This means that if the mempool contains 50 Mb of unconfirmed transactions, they won't fit into one block... Because the miner can add the fees of the sum of the transactions he puts into a block to the coinbase reward, it makes sense he picks the transactions with the highest fee (in sat/vbyte) to fill the block he's trying to solve. It also means that all other transactions won't be put into the block he's trying to solve, so they'll stay unconfirmed if he actually solves said block. Everybody getting payed in BTC wants their transaction to end up in a block (get confirmed), so they outbid other people that already have unconfirmed transactions in the mempool.
This boils down to a fee that changes depending on how much unconfirmed transactions are waiting, and which fee is payed by these unconfirmed transactions. If you want your transaction to have a high chance of getting into the next couple of blocks, you have to make sure you have a fee (in sat/vbyte) that makes your unconfirmed transaction be in the top 1Mb of the mempool (excluding the witness data).
An other thing to keep in mind is that the fee isn't fixed to the dollar (or euro, or whatever fiat money you're using), nor is it fixed for one transaction.. You pay a fee in sat/vbyte. Usually, the more inputs are used for your transaction, and the more outputs are created, the bigger your transaction is, so the more fee you'll have to pay. Bigger does not mean higher value... If you use 4 unspent outputs with a value of 0.00001 BTC as input and create 3 new unspent outputs of 0.00001 BTC, you'll usually end up with a bigger transaction than if you use 1 unspent output with a value of 100 BTC as input creating 1 new unspent output of 99,9999 BTC as output (eventough the second transaction transmits a much higher value).