Meaning of `pkgdir`

Calling Pkg.activate (in Julia 1.5.3) seems to change the output of pkgdir.
My situation is as follows.

Two versions of a package X, say, are installed, a released one in ~/.julia/packages and a develop version in another place.
I load the latter version into my Julia session, and pkgdir(X) shows its path. Fine.

Now I call Pkg.activate with some directory path.

Afterwards, the result of pkgdir(X) depends on whether or not the activated directory contains a file Project.toml:
If not then pkgdir(X) returns the same as before.
But if yes then the path in ~/.julia/packages is returned.

Is this behaviour intended?
If yes then what is the recommended way to find the location of a loaded package?

I don’t see this. In both cases pkgdir(X) returns the directory where the develop version is located. Which is expected, as I have loaded the develop version and activating another environment after loading a package won’t change the pkgdir as the curretly loaded version is still the develop version I loaded first. To use the version in the newly activated environment you will have to restart the REPL. Can you give an MWE for what you observe.