No — they are related, but they are not the same game or even the same line of games.
Battlefield 2 arrived in 2005 as a mainline entry: large maps, deep squad management, a commander role, and a PC-first design that became the benchmark for the series.
Bad Company 2 is a spin-off. The Bad Company sub-series began on consoles with a smaller squad of scripted characters, a stronger single-player campaign, and the Frostbite engine's destruction. Bad Company 2 carried that identity forward and added the now-familiar class and unlock structure.
So: shared DNA, different branches. If you want the sprawling PC-style combined-arms experience, Battlefield 2 is the one; if you want destruction and a proper campaign, look at Bad Company 2.