I have found a solution.
The address that the firmware should be writen is not 0x08000000, but it has offset specified in Marlin firmware,
so every address has the offset.
You can find the offset in Marlin firmware folder ini/stm32f1.ini and there under the specified controller is directive called
board_build.offset = 0x7000
So if you upload the compiled firmware by st-link device and stm32CubeProgrammer software, you should specify the starting address with added offset.
In my case it is 0x08000000 + 0x7000 = 0x08007000
So only that solved my problem.
However I previously said, that I have erased the whole memory of the conroller so there is no bootloader.
This means that I cannot update the firmware via SD card anymore.
The bootloader has been written on the 0x08000000 address and there is just nothing.
The solution for this problem was found here.
PS: I am writing this, so if anyone comes across this problem, they can learn from my troubles and solutions.