I've had the same problem with lecterns, and no matter how much I replaced the block with air and then put in the new lecternwithnbt, the new lectern has the old NBTs. (although in the meantime I've put in a block of air to 'clear').
And 1.20 last pre realase.
I've seen the duplicate but in my case, I replaced the lectern with air (/setblock)
and 10 minutes later I replaced the lectern in the same place with a /setblock lecternwith NBT.
And even if the block was air for 10 minutes or more, it kept the old NBT.
Sorry, I didn't understand why it didn't work x)
Hello, you have to be on a block and keep the right click pressed, that will give you levitation.
And as explained, 80-90% of the time, the effect will be normal, but sometimes, the effect will make you fly much higher or much lower.
( you need to have activated f3 and look at the height )
Also, drink a milk bucket, you have to have no effect for my command to work, the command is only there to show in a simple way that the levitation effect sometimes bugs.
( repeat command block )