Yes, making merit to benefit oneself is a selfish action and I don’t think what you have collected is merit, its might be only good karma.
But from your example mentioned that one wishes to become a Buddha as a result of making the merit; is this actually a pure motivation as one wishes ultimately to gain something for oneself? I will say that usually our merit is dedicate to ultimate goal which is to achieve enlightenment so the merit still continue support us from life after life until we achieve enlightenment and it is nothing wrong. But a long the way of spiritual path in order for us to become enlightenment, we need to achieve wisdom and compassion as well and if you have bodhicitta mind with full with compassion, I believe you will not just dedicate the merit only to yourself as that is not the bodhicitta mind.
And every time when we dedicate our merit to other, we still collect the merit, it doesn’t not transfer to other.