That library is not yet equipped to handle Pico W, so you’ll need this patched library: https://github.com/PaulStoffregen/Encoder/pull/85/
So I’d suggest you remove remove the old encoder library and install it from this zip
https://github.com/jjsch-dev/Encoder/archive/refs/heads/master.zip