Preheat oven to 350°F (175°C). Grease an 8x8-inch baking pan with butter or line with parchment paper, leaving overhang on two sides for easy removal.
Heat a skillet over medium-high heat and add the diced pineapple with brown sugar. Cook for 3-4 minutes, stirring occasionally, until the pineapple is golden and caramelized. Transfer to a paper towel-lined plate to drain excess moisture.
In a large mixing bowl, whisk together the glutinous rice flour, granulated sugar, shredded coconut, and salt until evenly combined with no lumps.
In a separate bowl, whisk together the coconut milk, water, beaten eggs, melted butter, and vanilla extract until smooth and well blended.
Pour the wet ingredients into the dry ingredients and stir with a spatula until you have a smooth, pourable batter with no flour streaks remaining.
Gently fold in the caramelized pineapple chunks, distributing them evenly throughout the batter without breaking them apart.
Pour the batter into the prepared pan, smoothing the top with a spatula. Sprinkle toasted coconut flakes over the surface if desired.
Bake for 35-40 minutes, until the edges pull away from the pan and the center jiggles only slightly when gently shaken. The top should be golden brown.
Remove from the oven and let cool completely in the pan for at least 1 hour — this allows the texture to set properly. The mochi will firm up as it cools.
Using the parchment overhang, lift the mochi out of the pan and cut into 16 squares with a sharp knife dipped in water between cuts to prevent sticking.