Your question has to do with an important poker concept: board texture.
You must always consider what your hand is vis-a-vis according to the other cards on the board and how that board can improve. Overall, you should recognize that the more cards your opponent sees, the more value your hand loses - don't let them see more card than they need to.
In the case of your particular hand, it was misplayed. Two things should have jumped out at you:
- With two hearts on the board, a flush was likely
- You are vulnerable to other Aces because you have a weak kicker with the 4
While it doesn't apply to your hand, in the future you should also evaluate boards for straight possibilities too.
In regards to #1 above, the flush possibility requires you to bet into this. You should be betting quite a bit to "price out" the flushes. I would be betting at least 1.5x the pot, maybe even twice the pot. Why? Keep in mind that something that's still big, like say a half-pot bet, still gives your opponent 3-1 odds which is enough to continue with a flush draw. So you have to make the pot large enough to discourage them from continuing.
In regards to #2 above, you'd have to consider the other players in the pot. You now see three aces (two on the board, one in your hand). What is the opening range for the other players? What is the likelihood that their range includes Ax? Did their pre-flop betting indicate an A in their hand? If so, you need to consider that you have a weak kicker in your hand. I would still follow the above with a large bet but definitely slow down on the turn and river if you get called. If you get raised, it would be a very close call but I would consider folding.
Hope that helps.