At the end of the Spanish colonial rule period, the Cuban Revolutionary Party had devised its own flag for Cuba. Given the historic brotherhood of Cuba and Puerto Rico, the Puerto Rican flag was made as a mirror of the Cuban flag colors by the Puerto Rican section of the party (a group of 59 Puerto Rican exiles in Cuba acting in favor of Puerto Rican independence) as a gesture of solidarity between both islands' independence movements.
Sources: https://flagspot.net/flags/pr.html