How does the Bitcoin p2p network work? Does it need port forwarding? But does every peer node in the bitcoin p2p network need to have ports forwarded in order to participate? Otherwise, how does the p2p network work in the Bitcoin network?

I heard that there are some technologies for implementing peer-to-peer networks such as UPnP and Hole Punching, does Bitcoin use any of these technologies for its p2p network?
Nodes that participate in the Bitcoin network run a computer program such as this one: https://github.com/bitcoin/bitcoin, which dictates how everything works.

To answer your more specific questions:


Yes, bitcoin once used UPnP, here are some more details: https://dirkmittler.homeip.net/blog/archives/3340 but in modern versions it does not (thanks for specifying this the comment section). 
Bitcoin uses TCP, and hole punching over it is not reliable.. Here's another place where this is briefly touched upon Can exist bitcoin network with all nodes behind NAT?