Understanding specialization patterns of countries in food production can provide relevant insights for the evaluation and design of policies seeking to achieve food security and sustainability, which are key to reach several Sustainable Development Goals (SDGs). In this paper, we use production data from FAO for the period 1993 to 2013 to build bipartite networks of food products and food producing countries. We use methods from complex systems analysis to rank countries according to their capabilities or competitiveness and products according to their sophistication or need of capabilities. Competitiveness is quantified by the fitness of countries, which measures the quality and how diversified are their food production baskets. We observe two well-defined communities of food producing countries, one clustering countries with relatively developed agricultural systems, and theother one grouping only developing countries. We use network statistics on food production and specialization patterns, and we perform an econometric analysis to study whether and how specialization patterns affect food supply, food security, and sustainability of food systems. We show that concentrating agricultural production decreases food supply, food security, and sustainability of food systems. The competitiveness or fitness of countries as well as the coherence of diversification patterns, both increase per capita food supply and food security (SDGs: Targets 2.1 and 2.2) but might have a negative effect on sustainability (SDGs: Target 2.4). This reflects the trade-off between achieving food security while simultaneously improving sustainability, which needs to be considered when developing or implementing policies seeking to reach SDGs. Given that the position of countries in food trade dynamics also affects their decisions in food production specialization, the analysis opens the ground for trade policy considerations (SDGs: Target 2.b).