Sorry if it sounds lame.
Let's say if there is a proposal and community has voted their choice for a protocol upgrade.now my question is does tezos dev team needs to code the change or the protocol some how magically self upgrades?
Proposals are not just ideas, they must be pieces of code that patch the existing protocol. Once if they are adopted, the protocol gets recompiled on the fly and the chain carries on with the new code base.