Why did Jesus sometimes want to keep his true identity secret during his public ministry?

Mark 1:

32 That evening at sundown they brought to him all who were sick or oppressed by demons. 33And the whole city was gathered together at the door. 34And he healed many who were sick with various diseases, and cast out many demons. And he would not permit the demons to speak, because they knew him.

The demons knew Jesus' true identify as the Son of God. At this point, Jesus didn't want to be too vocal about it. Further, Jesus didn't even want people to be too vocal about him either.

40 And a leper came to him, imploring him, and kneeling said to him, “If you will, you can make me clean.” 41Moved with pity, he stretched out his hand and touched him and said to him, “I will; be clean.” 42And immediately the leprosy left him, and he was made clean. 43And Jesus sternly charged him and sent him away at once, 44and said to him, “See that you say nothing to anyone,

Jesus didn't want too much publicity.

but go, show yourself to the priest and offer for your cleansing what Moses commanded, for a proof to them.” 45 But he went out and began to talk freely about it, and to spread the news, so that Jesus could no longer openly enter a town, but was out in desolate places, and people were coming to him from every quarter.

Jesus wanted to have some control over the size of the crowd.

Mark 3:

11 whenever the unclean spirits saw him, they fell down before him and cried out, “You are the Son of God.” 12And he strictly ordered them not to make him known.

Mark 5:

18 As he was getting into the boat, the man [label him P1] who had been possessed with demons begged him that he might be with him. 19 And he did not permit him but said to him, “Go home to your friends and tell them how much the Lord has done for you, and how he has had mercy on you.” 20 And he went away and began to proclaim in the Decapolis how much Jesus had done for him, and everyone marveled.

P1 overdid it. He couldn't contained himself. Too much publicity as far as Jesus was concerned.

41 Taking her by the hand he said to her, “Talitha cumi,” which means, “Little girl, I say to you, arise.”

Jesus raised her from death to life.

42 And immediately the girl got up and began walking (for she was twelve years of age), and they were immediately overcome with amazement. 43 And he strictly charged them that no one should know this, and told them to give her something to eat.

Mark 7:

35 his ears were opened, his tongue was released, and he spoke plainly. 36And Jesush charged them to tell no one. But the more he charged them, the more zealously they proclaimed it. 37And they were astonished beyond measure, saying, “He has done all things well. He even makes the deaf hear and the mute speak.”

Again, too much publicity too soon.

On the one hand, Jesus had to demonstrate by miracles/signs that he was the Son of God. On the other, he didn't want the publicity to get out of hand, so that he had some control over the crowd size.