Very basic question about 16x2 LCD display scrolling

I modified an existing WOKWI-simulation and analysed how the LCD-code reacts on different lengths of the text.
For a single line you can print 40 characters
So by inserting spaces at the beginning the existing scroll-function will scroll in blanks which are not distinguishable from no printing at all

As your code uses a for-loop and delay() both things are blocking code
as long as the delay is active no other code can be executed
as long as you are in the for-loop only the code inside the for-loop is executed and no other code

This WOKWI-Simulation uses a non-blocking timer-function which enables to blink the blue LED all the time even in parallel with the scrolling of the text.

Doing things in parallel means more and a little bit more complex code.
It is very normal that you will need some time to understand it

Here is a tutorial about the basic priciple of non-blocking timing

best regards Stefan