You probably have a mutli-core CPU, so both parent and child can both be running on separate CPU cores. Printing is slow enough that the parent process has time to gets its 1st print started before your child process's 2nd print starts.
Or if not, on a single-core machine then scheduling could context-switch after one print.
The whole point of fork
is to create a 2nd process that's also running; there should be no expectation that their system calls don't interleave with each other.
Existing near-duplicates about fork race conditions / timing, although those primarily about which runs first, not any expectation of continuing to run for multiple system calls before the other process can do anything.
And more generally Understanding parent and child process execution order about making multiple system calls including read
in both parent and child, causing one or both to block.
And two where people had the opposite problem: they expected interleaving of output but didn't get it. (Perhaps because of buffered I/O resulting in only one write
system call, if run from an IDE with output connected to a pipe instead of tty perhaps.)