The counter for heading.where(level: 1) is not the one you want, you need counter(heading) instead and it will work.
A single counter contains multiple levels of numbers, so there is just a single counter for all headings. You can check the docs for counter.update on how you would use it when using multiple heading levels—for the shown code, your current approach simply works.
for the second approach, you need to use ..n.pos(). n is an arguments value (which can contain positional and named arguments) but you need an array (with the positional arguments in it), thus pos().