The first example, when she was masturbating, is normal and all you need to do is instruct her to do this alone in a private area, such as her room. The second example is different. Set a firm limit on the behavior it is not allowed, plain and simple. Be sure to supervide her when she is with peers to be sure there is not a repeat of this. It would be wise to have a chat with her about her behavior with the boy. You'll want to learn how this occurred to her, to see if there was any experience about which you should know.
Thank you. I had a talk with her. She claims she sees princesses and princes kissing in the movies she watches and she wanted to try it. We had a long talk about her age and the age of those princesses and I think she understands that behavior is not something she is really ready for.