买 is a transitive verb; 买东西 is a separable Verb-Object structure, so the number + measure goes between.
Examples:
to eat/ to have eaten a meal
吃飯/ 吃了一頓飯
to sing/ to have sung two songs
唱歌/ 唱了兩首歌
to shop/ to have shopped three times
買東西/ 買了三次東西
to tell a story/ to have told several stories
講故事/ 講了幾個故事
With intransitive, multi-syllabic verbs that cannot be separated, the number + measure goes after.
Examples:
to perform/ to have performed one show
表演/ 表演了一場
to complain/ to have complained quite a few times
投訴/ 投訴了好幾次