You're asking "how does blockchain work?" without asking "how does blockchain work?" To answer your question requires a literal lesson on how Ethereum works. It's clear that you've not taken the time to understand the fundamentals of blockchains or network design. If you seriously want to understand or develop on blockchains, I highly recommend you get used to reading ALL of the documentation before you ask any questions. This is still novel technology. Start with the white and yellow paper, then read all the documentation on their site if you really care about this. I'm only answering this because I'm writing an article on creating a 100% Ethereum-based marketplace, and can copy and paste most of the info, I would be flagging as low quality, which I don't do often.
What have you tried? What resources have you already read? What's the context of why you're asking the question? What information do you seek to gain?
I still recommend reading all of the official Ethereum documentation, consider how much time it took people to put it together, and reflect on that before asking vague questions.
Your Answers, Sir/Madam/Zer/Zim/Non-Binary/Astral/Zoologic/or fluid-gendered member of the Human species:
For the context of your question, think of Ethereum network like the back-end software of any program (DApps in this case). This back-end is the Ethereum Virtual Machine (EVM) which is powered by nodes; they are responsible for ensuring the data passed through the EVM is valid, but you don't need one to use the network. Users interact with code on the EVM using software clients which use code libraries like Web3.js to "talk" to the blockchain. It's like making API calls, with a few differences. Check out MetaMask as a good example of an Ethereum client.
A decentralized marketplace is a P2P market, but a P2P market does not have to be a decentralized marketplace. The difference is a general P2P market can use any software stack it wants to accomplish the end result. As long as the client software can communicate data with other instances of the software, and there is no middle-man (peers are interacting directly with each-other), you have a P2P network.
A decentralized, blockchain marketplace has specific requirements. Changes of any kind within the market (adding a product, accepting payment, adding admin, adding user-accounts, price changes, inventory checks, etc., etc.) each require a smart contract to handle the process. Smart contract calls are like API calls, with one major difference:
In order to incentivize nodes to take the data you send, run data-intensive calculations to verify it, and add it to the blockchain, all contract calls have an associated gas fee (amount of ETH). The higher gas fee, the more incentive a node has to include that transaction, as the fee goes to them. This gas fee can be changed by the user (increased to make it more lucrative to take, or decreased if time is not a constraint). By requiring that every action cost an asset with real-world value, it helps get people to play nice.
There are pros and cons to each. For example, a 100% Ethereum blockchain could do things like utilize any ERC-20 token as payment. The data is secure due to the size of the network and the consensus algorithms being used. A hacker cannot simply find a loophole in the Ethereum network itself and cause trouble like they could if the market was a Web app or a desktop client. This benefit is also the main drawback, every action requires payment. If ETH is expensive ($1200 at the time of writing), and the contracts are intensive and require a lot of gas things can get expensive.
For example, right now a simple call just to tell the EVM that I authorize a smart contract to utilize my assets in a passive-income DApp costs over $12 worth of ETH to accomplish in less than 10 minutes. Once that's done, I'll need to make an even more complex call to a contract that allocates my funds, this will likely be close to $50 if I want it done quickly.
- It's Blockchain, and it's both. Smart contracts are the code of the EVM, just like Java or C# or any other language is the code of any P2P network. The blockchain itself is nothing more than a large, distributed network who's purpose is to run cryptographic consensus algorithms. A blockchain is P2P by definition, there is no "under the hood". It is a network of tens of thousands of people who don't know each other, spread all around the world, all running the same software to keep the same network running so that data can be compiled and irreversibly, publically, and permanently added to the network.
By design, this network also functions as a ledger of every transaction that has ever happened on it.
P2P is so broad, it can be accomplished with any tech stack. You don't need a node. You can have a server, make a web app that connects users, and run it like a normal website and it's still P2P. You can create a client that runs on a specific port using a specific protocol to allow users to perform P2P actions. Keeping the system up, whether it's Ethereum (nodes) or a web app (the internet) is dependent on whatever system it's built for. Ethereum is just a network like the internet that uses a different consensus method to validate data.
Blockchains are public. Whenever data gets validated by a node, it gets added to a block. Unless you're running a node and can enter the queries into the console, you need a client app or UI. Node operators can get raw data from their computers. Most users need a website or program that is designed using a code library that can interact with the blockchain. Again, a blockchain is just a network. A search engine of any type requires three things: A search function like box or filters in the user-interface, a source of raw data like a network back-end or blockchain, and a code library that bridges the two (an API, or in the case of blockchains, ABI).
The smart contract is the API (ABI actually). It is decentralized. The software people use to interact with the contracts is not. Unless you're running the blockchain, you will never talk to a node directly. In order to search for data on a blockchain, it must have been validated by the nodes at some point in the past. When you make a call to the smart contract, it talks to the entire network. The nodes work behind the scenes, they validate the data.
Sure, you could technically make a protocol that finds a specific ETH node, checks what transactions it's putting together to include in a block, and look at that. It not only won't do you any good because it might not even bee the node to solve the block and therefore all the transactions it was working to include in a block remain pending or were validated by another node, but it's a topic that requires a chapter in a textbook to understand completely.
- It uses code libraries, like every other software to achieve things without reinventing the wheel. Web3.js is a common library designed to interpret the compiler code from the blockchain into human-readable and interactive uses.