No, you did the wrong thing. You did not know it was wrong but it very much is.
At my parish, Father has the ushers on guard on all sides to make sure the people receiving communion actually consume it at the altar as they are suppose to do.
One lady did much like you did and Father had the woman blocked off at the church entrance as she was leaving. He confronted her (kindly mind you) and asked if she was Catholic, (yes) are you intending to consume the host at the altar. (no…she wanted to take it home for later) so he politely made her give it back to him.
Part of the Rubric’s of proper disposion to receive is that you have fasted one hour before receiving but also must receive at the Mass. No Carry outs allowed.