When searching for “heimberg” with country bias Switzerland (CH), there are only results for “heimberg” in Germany. Only when explicitely searching for “heimberg (ch)”, the location (“osm_id”:1682472) is among the results.

Why is that?

voilà:

https://nominatim.openstreetmap.org/search?q=heimberg&countrycodes=CH&addressdetails=1&format=json&accept_language=de

It is countrycodes, not countryCodes (check the differences to your first example link). The query parameter keys don’t use camelCase…