I just tried some Processing Python example code on a Mac M2 and had trouble also. The files in ‘Examples/Python Mode Differences’ would run but none of the others that I tested. If you know how to use pure Python the Thonny editor might be a better choice.
See other current thread: https://discourse.processing.org/t/is-a-fresh-install-of-processing-3-5-4-and-python-mode-possible-mac-os/44104/2
Addendum:
I tried writing a simple demo with my M2 using a fresh download of version 3.5.4 from the website Processing.org and it ran ok. The code that I tested follows:
def setup():
size(400,400)
def draw():
fill(255,0,0)
circle(width/2,height/2,100)