My two cents on this topic.
There are two similar concepts. Projection and focus. I will make a step-by-step list.
1. A scene can be viewed when it receives light and the light is reflected. Depending on the materials light can be reflected in a lot of directions (dispersed) when it hits a diffusive material.
2. When you can isolate some of those rays making them pass through a hole and forget about the rest, and when the light inside the room is dark enough, you get a projection on the opposite side.
Some rays from specific sources on the scene A will hit different zones of the wall B, C, D
3. If the hole is small enough the rays are projected on a specific point on the wall because the others are left out.
4. When using a lens, you take those additional rays C, D and bend them using refraction so now they also hit the intended point on the wall B.
So far so good.
In photography a focused point is a point of the projected image, but only when the most amount of rays coming from a specific point from the scene (A) are hitting the same point (B).
When using a lens you refract them so they hit that point. On a pinhole camera, the only way to do that is not to allow those divergent rays to enter the room in the first place. The narrower the hole the more selective you are, the more focused the image you have.
https://www.pexels.com/es-es/foto/puerta-azul-cerrada-462205/