Isn't fee the difference between the sum of inputs and sum of outputs?
Correct. Whatever amount of bitcoin you don't specific an output for will be consumed as a fee.
In the first transaction you linked, your input was 8000 sats and you only specified a single output of 2000 sats, so the remaining 6000 sats was used as a fee. If you did not want to spend all that on a fee, then you should have specified an additional output to a change address of say 5500 sats, leaving 500 sats unaccounted for which would have been taken as the fee.