What @david_2018 Is saying is that, once your sketch starts running, the Neopixel library will try to allocate 3 bytes of ram memory per led in your matrices, to hold the colour information of each led. That's 1.5K of the 2K ram memory available on Uno. It appears that @david_2018 compiled the code you posted and saw that it requires some ram for the sketch to use while running, leaving less than 1.5K left. When the sketch starts to run, there won't be enough to allocate the 1.5K needed, and all manner of strange things will happen, which could easily explain what you have seen.
Was thinking about this again, shouldn't the problem be also when I run the first code? without the bluetooth? Because with the first code I can have both matrices running without any problem