Contracts only see what is on the ledger. They cannot check the price of gold or whether a market is open. An oracle is a service that publishes such facts on-chain, usually signed by several independent reporters so that no single one can move the number.
Good oracles report how fresh each value is. A lending market should refuse to act on a price that has not been updated for hours, and a well-written contract checks that timestamp every time.
Two kinds of price
Some prices come from reporters who watch traditional markets. Others are read from trading pools on the chain itself, averaged over time so that one large trade cannot distort them. Both have a place; the first suits assets that trade mostly off-chain, the second suits tokens whose main market is on-chain.