You’re right that “go” is an intransitive verb in this sentence: “I go to school with my friend.” However, “my friend” is not the object of the verb “go” in that sentence; it is part of the prepositional phrase “with my friend,” which is an adverbial phrase modifying the main clause “I go to school.” In that main clause, the noun “school” is actually the object of the preposition “to”; this preposition transmits the action of the verb “go” to the object “school.” As an intransitive verb, “go” can’t take an object, but in this particular construction, it uses the preposition as an “intermediary” for transmitting its action to the noun “school,” which then functions as the so-called “object of the preposition.”
When an intransitive verb uses a preposition to transmit its action to an object in such situations, that verb doesn’t change into a transitive verb. It remains an intransitive verb, but one that has to use a preposition to grammatically connect to an object. It is unlike a transitive verb, which as we know always needs a direct object to be able to function properly in a sentence. (For instance, when we drop the direct object “cars” in the sentence “Fred fixes cars for a living,” the transitive verb “fixes” no longer functions properly, and nor does the sentence itself, as we can see in the following object-less, nonsensical construction: “Fred fixes for a living.”)