What is a mechanism of method how to get the data in the blockchain(e.g. bitcoin, ethereum)? There are websites which have APIs that allow you to trace transactions and lookup information like specific address balances, etc. I am wondering how these web service providers are able to provide the data from the blockchain.

I think that they are running a full node 24/7 so that the end user does not need to run tun their own node and can instead query for data via the service's node.
Blockchain explorers run multiple nodes which receive all blocks and transactions. They store these blocks and transactions in various databases which allows them to write software which query those databases whenever a user requests information about a block or transaction. They will also do additional processing of the blocks and transactions to produce information such as addresses and be able to provide all of the transactions for a particular address.

When you lookup anything on a block explorer's website, you are not actually sending a query to their node, that would be far too inefficient. By using external databases to store information, they can quickly lookup data in order to return it to the user.