Why was Yaacov punished for hiding Dinah from Esav? Isn't this an expected attitude from a loving and protective father?
Yaakov locked Dinah inside a chest to keep Eisav from setting eyes on her and wanting to marry her. However, Yaakov was punished for this because had he let Eisav marry Dinah, perhaps Eisav would have become a tzaddik.
(Rashi on Bereishis 32:23 quoting Bereishis Rabbah 75:9)
another source in Mesilat Yesharim ch.4
And expounding on "it is very stormy round about Him" (Ps.50:3) - "this teaches that the Holy One blessed be He scrutinizes judgment on His pious ones to the degree of a hair's breadth" (Yevamos 121a)...
Yaakov, for replying angrily to Rachel when she said to him "give me children", the Midrash reports (Genesis Raba 71:10): "the Holy One blessed be He, said to him: 'is this how one answers a distressed person? By your life, your sons will stand before her son'.
And for hiding his daughter Dina in a box so that his brother Esav would not take her as a wife, even though his intent was certainly good, but nevertheless for merely witholding kindness from his brother the Midrash reports: "the Holy One blessed be He said to him: 'He who withholds kindness from his fellow..' (Job 6:14). You did not seek to marry her to a circumcised? Behold she will be married to an uncircumcised. You did not seek to marry her in a permitted way? She will be married in a forbidden way".
this says that
his fault was extremely fine (to a "hair's breadth")
his intent was certainly good
nevertheless, since he withheld good from his brother, he was punished for that.
could be he was fully justified but nevertheless was punished as we find Yaakov was punished for not doing the mitzva of honoring his parents for the 22 years he was in Charan (Yosef disappeared for 22 years) even though he was commanded by his own parents to go there.
The Tolna Rebbe comments on the fact that Yaakov Avinu locked the box. What was the purpose of the lock? Surely Eisav wasn't expected to rummage through all the boxes?
He explains that the lock was to keep Dinah in against her will if need be. Dinah took this as an insult that she was also not to be trusted. That feeling burned within her. Therefore, she accustomed herself to go out and explore out of resentment that she was not trusted by her father. This resulted in Shechem being able to take her.
I have also heard, that others in Yeshivah explain (no specific source) that Yaakov Avinu's attitude was judged to be a bit too extreme. It was for this extra "nose in the air" assumption that his brother was unsalvagable, that he was held accountable by Hashem.
However, the general idea that he wanted to protect Dinah from Eisav was a proper idea of course.
I hope this helps. :)