Ferroelectric crystallites embedded into a dielectric matrix experience temperature-dependent elastic strains caused by differences in the thermal expansion of the crystallites and the matrix. Owing to the electrostriction, these lattice strains may affect polarization states of ferroelectric inclusions significantly, making them different from those of a stress-free bulk crystal. Here, using a nonlinear thermodynamic theory, we study the mechanical effect of elastic matrix on the phase states of embedded single-domain ferroelectric nanocrystals. Their equilibrium polarization states are determined by minimizing a special thermodynamic potential that describes the energetics of an ellipsoidal ferroelectric inclusion surrounded by a linear elastic medium. To demonstrate the stability ranges of such states for a given material combination, we construct a phase diagram, where the inclusion's shape anisotropy and temperature are used as two parameters. The 'shape-temperature' phase diagrams are calculated numerically for PbTiO and BaTiO nanocrystals embedded into representative dielectric matrices generating tensile (silica glass) or compressive (potassium silicate glass) thermal stresses inside ferroelectric inclusions. The developed phase maps demonstrate that the joint effect of thermal stresses and matrix-induced elastic clamping of ferroelectric inclusions gives rise to several important features in the polarization behavior of PbTiO and BaTiO nanocrystals. In particular, the Curie temperature displays a nonmonotonic variation with the ellipsoid's aspect ratio, being minimal for spherical inclusions. Furthermore, the diagrams show that the polarization orientation with respect to the ellipsoid's symmetry axis is controlled by the shape anisotropy and the sign of thermal stresses. Under certain conditions, the mechanical inclusion-matrix interaction qualitatively alters the evolution of ferroelectric states on cooling, inducing a structural transition in PbTiO nanocrystals and suppressing in BaTiO inclusions some transformations occurring in their bulk counterpart. The constructed phase maps open the possibility to calculate dielectric properties of strained PbTiO and BaTiO nanocrystals and ferroelectric nanocomposites comprising such crystallites.