I created two models using the lm() function in R. The first model, I created the design matrix for my prediction variable and then fed that into the lm() function.
copy <- data.frame(mtcars)
reduced_copy <- model.matrix(~cyl + hp, data = copy)
mpg <- copy$mpg
copy_model <- lm(mpg ~ 0 + reduced_copy)
print(summary(copy_model))
The summary of the model is below:

For my second model, I converted the cyl variable into a factor and then created a model from the data.
copy2 <- data.frame(mtcars)
copy2$cyl <- as.factor(copy2$cyl)
copy2_model <- lm(mpg ~ cyl + hp, data = copy2)
print(summary(copy2_model))
And the summary of the model below:

The intercept and regression coefficients are the same for both models. What I do not understand is why the R-Squared Values for each are so different. From my understanding, the lm() function creates a design matrix under the hood, so I figured that the two models would be the same, if not very similar in their results.
cyl4level, and copy_model showscylas continuous rather than a factor. It would be good to check the output.