I think it's a really interesting question. Like the whole- is there such thing as true altruism?
In general terms, morality is a human construction. I think there are complex reasons we choose to act in a moral way or not and I agree- I feel like a lot of it is what we have been taught- what's ingrained effectively. So- whether we can live with ourselves if we contradict our learned sense of right and wrong.
I think altruism does play a part though via empathy. Can we stand to watch someone else suffer or, will we try to help them? Again- some of that is taught- we're often taught to help people who are struggling. But, I think some of it is innate.
Whether that can be classed as 'good' though- if it is actually innate- is something else. I think it was Richard Dawkins who said we have developed altruistic genes because we live in societies. It benefits us as a species to work together in a society environment.
With regards to the actual question, I can see it from @Trismegistus_13 point of view- that a good act does good whether it was well intentioned or not. Their example of giving to charity is true obviously. However, I'd argue that it is possible for something to look moral outwardly when in fact, the truth is murkier.
This is a very extreme example (NSFW warning for child sexual abuse) but I think most people would have problems with this for example: Jimmy Saville (a UK TV entertainer) was estimated to have raised £40 million for charity. He also sexually abused hundreds of children.
Was it 'moral' of him to raise money for a new development at a hospital where he went on to abuse the patients? The hospital did and I'm sure still does a great deal of good too. I imagine most people would agree though that his involvement with it wasn't for altruistic reasons- even if he raised £40 billion! It was obviously a smoke screen to conceal his true identity and it gave him access (literally) to vulnerable victims.
So- in my opinion- it depends. It's not to rubbish what good people do for this world. I personally find it curious to ponder about our motivations for things. Even our own motivations for things. Some people take huge offence at that. I guess it is a rather cynical view of people but, I'll hold my hands up to being cynical. Even of myself.
In part though because- sometimes it is necessary to question someone's motives. In the very worst and extreme of cases- like the Saville case- maybe if people had looked a little closer (although, it seems like it was almost an open secret) and questioned whether he was really as good as he pretended to be. Why he wanted so much access to children's hospitals- maybe hundreds of them could have been spared being molested or raped. I expect they still would have raised a lot of money without his help.
Some of it is to protect ourselves. If a stranger offers a young, attractive female a ride home in his car- should she accept? On the face of it- it seems like a kind act. If I had a daughter though- I'd tell her not to accept it. Not worth the risk. (Proabably goes the same for anyone- regardless of gender or looks to be fair. Getting in a strangers car carries risk for both parties.)
Of course- I'm not saying all people who raise money for children's charities are doing it for ulterior, perverted reasons. That's such an extreme example but I'd argue- it is a legitimate one. A minority of people do indeed use moral acts to disguise what they're really up to.
I think the degree as to which it is still a good act or isn't depends on how bad their ulterior motive is. If it's simply to feel good about themselves, that's nice really. They are obviously good deep down- for whatever reason. A well mannered upbringing, kind genes. If they're using it to try and improve their tarnished image, maybe we might feel a bit cynical towards them still but hey- at least other people will benefit. If it's to mask criminal intent though- that's something else. Can anyone truly accept that in order to raise millions, even billions- someone or multiple people will get hurt? I doubt any amount of money can excuse child molestation and rape.