Of course they can. Otherwise people could simply mail illicit substances in small batches because no customs agency on the planet would have the manpower to contact each and every recipient and open their mail only while they are present.
Well, sometimes they do plant things in luggage for training purposes. It gets messy when the sniffer dogs can't find it, the agent forgets to put the "This is a plant! Signed, Customs" label on the coke pouch and then fails to locate and remove it. I'd Google it but my VPN isn't working and the CPC is so vewy afwaid of people finding out things.
Like everyone else already said, yes they can open everything entering the country. The only reason you are present at the airport when they open and search your suitcases is because they want to have a look at you while they do it and ask you question (so that you ideally confess to everything etc). It wouldn't be legally nessecary for you to be present. That's just a law enforcement trick to get you sweating and talking (if you'd done something wrong).
My fear is just that they can steal stuff from my package or plant drugs or something and I'd have no way of defending myself.
Concerning the Drugs: You send the packages to yourself? You are recipient and sender at the same time? Only in that case would that be a real risk to you. Having not send the packages, they'd be able to charge you - but would have to prove that you orderd this. Which would be hard - if you really hadn't ordered drugs somewhere.
But yeah, if law-enforcement is crooked and wants to plant something on you - you'll always be in trouble, everywhere. Horror Stories like that are readable everywhere.
Stealing - that's more likley with baggage handlers or postal-service employees than custom agents. But of course possible. And the officers of course risk you filing charges against them if they steal from you ...
Another thing is, Portugal has one of the most liberal Laws towards the posession of illegal drugs in Europe. As long as you're not Walter White, you'll be fine
They confiscated all 40kg of my cocaine I'm pretty sure drugs are still illegal in Portugal, but decriminalized.
Anyways, I did send the package to myself, yes - just stuff for our wedding. Seven packages, to be exact - in the end I was only able to retrieve six of them. Luckily the seventh was the least important.