For instance, if you use an Apple phone and the government wants to see the pictures you took, they can just get a copy of them from Apple using iCloud.
Yes, using a warrant from a court. If the government wants to break into my house they can also do that with a warrant. Not exactly the same as having a key to my house though, and very far from a malware.
Also to be more specific, In apple ecosystem I can opt for encryption where they can't
You're free to opt out of icloud/gcloud and the government will have a tough time extracting the pictures from your phone, as multiple lawsuits have shown.