it is quite normal for friendly countries like the US and India to have spooks at embassies and consulates under various covers. Typically, the governments also exchange the identity of the spooks.
I don’t get the second part. What’s the point of being a spy if the spied-on party knows you’re a spy ??
My guess is that there are often times when countries want to get information to each other “unofficially.” In those instances, it’s really nice to know into whose ear to whisper. But, for every known spy, there are probably three hidden.