Where is Ubuntu storing installed programs?

You can use apt list

filter out by name of a package
apt list | grep nginx

but it’s not stable CLI interface
you can use dpkg

dpkg --list | grep nginx

you can use a pattern like x* to show all package started with x you can do that if you would like to filter out the package with a particular pattern
dpkg --list x*