Context is one of the tricky bits of Typst.
To quote Typst's designer:
the context value itself becomes opaque. You cannot peek into it, so everything that depends on the contextual information must happen within it
For the full explanation: https://forum.typst.app/t/why-is-the-value-i-receive-from-context-always-content/164?u=vmartel08