Confusion about when a JK flip flop is triggered
You have discovered the drawback of the Master-Slave JK flipflop.

The M-S JK flipflop is not edge triggered, it is pulse triggered.

What you have discovered is a phenomenon which M-S JK flipflops suffer from known as 'ones catching'.

This is when noise on the J or K inputs whilst the clock is high can alter the resulting outputs of the flipflop.

To avoid this drawback of the M-S JK flipflop the clock pulses should be kept short or avoid Master-Slave flipflops altogether and use true edge triggered ones.



You could look up 'ones catching' for more info.