Can I use horizontal 90 degree elbows to run a p trap along a wall?
The specifics of this largely depend on your local plumbing code, and so what is acceptable during an inspection depends on that. Your inspector will be able to tell you for sure.
Elbows
My reading of Ontario build code section 7.5.6.3 says this would not be allowed:

(c) the trap arm does not have a cumulative change in direction of more than 135°.

90+90 = 180°, so that's too much.
Trap Arm Length
The other factor is trap arm length, and that depends on pipe size. Since this is a vanity I'll assume 1 1/4&quot;. To make that work, you need:

1.5m (5 ft) maximum length
1:50 slope (eg, 1/4&quot; drop for every 1')

Fix
One option, if there's space, is to use a 90+45 (135° total) to route the pipe out:

Or you could also do it the other way around, though that would require opening the wall and cutting into the vent stack:

And if you're going to cut into the wall anyway, another option is re-route the pipe to use a single 90:

Which one makes more sense is going to depend on space available and where the studs are.