Like Germany, the history of Italy is not the history of a united country, but of a mix of kingdoms and principalities and free cities, whose political powers and geographic boundaries shifted over the years.
Looking at a map of Italy in 1800, you find Venice, Padua, Verona, and the Italian Alps are part of the Austrian empire. You find that Milan, Mantua and Bologna are within the Cisalpine Italian Republic. Turin is actually in France. Parma is in its own duchy. Genoa is in the Ligurian Republic. Lucca is a small independent state. Florence is in the Kingdom of Etruria. From Rome to Ancona, you are in the papal states. Below Rome, you are in the Kingdom of Naples.
Then came Napoleon. Napoleon created the Kingdom of Italy, starting with Milan and the rest of the Cisalpine Italian Republic, gaining Venice and the other territories which had belonged to Austria, and actually adding the Dalmatian coast, on the eastern side of the Adriatic. He invaded and occupied the Papal States and proclaimed them a historic part of the French empire. The Kingdom of Naples remained separate, but was governed by King Joseph, who happened to be Napoleon’s brother. Only Sicily was not controlled by Napoleon.
Things changed again after Napoleon’s defeat. Sicily joined with the Kingdom of Naples to create the Kingdom of the Two Sicilies. The Papal States were receated, this time expanded to the north on the Adriatic coast. Florence and Siena wound up in Tuscany. Genoa and Turin were now part of the Kingdom of Sardinia, as was the island of Sardinia. And Venice and Verona were back under Austrian control.
Over the next 30 years, the concept of a united Italy began to gain prominence, particularly due to Giuseppe Mazzini, culminating in revolutionary activity in places such as Milan and Rome. Perhaps the most successful revolt was in Rome itself, with the Roman Republic declared in 1849. But this did not last long, as the Republic was, to the Italians’ surprise, invaded by Louis Napoleon of France. The French remained in Rome until 1870.
In 1861, after considerable additional confusion, Giuseppe Garibaldi was able to declare the existence of a new Kingdom of Italy under the House of Savoy, with Victor Emmanuel as king. The Kingdom of the Two Sicilies, everything south of Naples, as you recall, joined the Kingdom, basically uniting Italy for the first time since Roman times. But the city of Rome (still under French occupation) was not included, nor was Venice and the remaining territories still controlled by Austria.
It was not until 1866 that Venice became part of the Kingdom of Italy, and not until 1870 that the French were forced out of Rome, and Rome was incorporated into, and declared the capital of, a united Italy.
By the way, the Vatican City was not established as an independent political entity until 1929, when the Pope and Mussolini struck a deal. The Vatican would become independent and Italy would exert no control over it, and the Pope would make sure that the Catholic Church would not interfere with the secular nature of the remainder of Italy.