You can make flexible solar panels, and you can make them in non-rectangle shapes. They are, I believe, commercially available.
Most solar panels are rectangular because the surface they’re on is rectangular, and rectangles are easy to tessalate so you don’t need (too many) different sizes/shapes to cover a large area. Making them flexible means making them thinner and less durable – which isn’t worth the flexibility for a vast majority of applications – though in some niche cases, it sees use.
I’ll let someone else answer the first part, since I don’t know enough about it to ELU5
they are made by putting two layers of different semi-conductors on glass or transparent plastic. Sunlight makes electricity flow from one layer to the other.
They can be made in any shape, rectangles are just easier to produce and move and install. You can cover your roof with hexagons, but frame holding them will be more complex than with rectangular tiles.
There are flexible solar panels, e.g. for use on backpacks or clothes. They are not super flexible (more like cardboard than cloth), because if semiconductor layer cracks from too much bending, it will stop producing electricity.
Solar panels are made up of variants of silicon crystals. Each cell is a crystal that have been carefully grown in a lab to have these special properties. The crystals are like most crystals hard as rock and brittle. We make them into rectangles because it is convenient for us. Actually the cells are made as circles and then cut into squares so they are easier to work with. The advantage of using rectangles is that it is easy to stack them without any gaps between the cells. It is not impossible to make triangular solar panels, you can even make it fill all the space. However it is not as easy and there are a lot more constraints in doing this.
Latest Answers